﻿using AppDataStruct;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace EECMISWS
{
    /// <summary>
    /// 人口信息的查询来源（省户籍信息，省常住人口，全国人口库）
    /// </summary>
    public enum QueryFrom : int
    {
        Household = 0,  //省户籍信息
        Reside =1, //省常住人口
        QG = 2, //全国人口库
    }

    /// <summary>
    /// 人口库信息查询结果
    /// </summary>
    public class PeopleQueryResult
    {
        /// <summary>
        /// 查询结果最终来源
        /// </summary>
        public QueryFrom DataFrom { get; set; }

        /// <summary>
        /// 查询是否成功
        /// </summary>
        public bool Success { get; set; }

        /// <summary>
        /// 查询结果是否有数据
        /// </summary>
        public bool HasData { get; set; }

        /// <summary>
        /// 相片数据是否保存成功
        /// </summary>
        public bool HasSaveXP { get; set; }

        /// <summary>
        /// 如果查询包含多个来源，每个接口返回的错误消息以$分隔
        /// </summary>
        public string ErrorMessage { get; set; }

        /// <summary>
        /// 人口库个人信息
        /// </summary>
        public QGRKInfo PersonInfo { get; set; }

        /// <summary>
        /// 错误代码
        /// </summary>
        public string ErrorCode { get; set; }

        public PeopleQueryResult()
        {
            Reset();
        }

        public void Reset()
        {
            ErrorCode = "";
            DataFrom = QueryFrom.QG;
            Success = false;
            HasData = false;
            PersonInfo = new QGRKInfo();
            ErrorMessage = "";
            HasSaveXP = false;
        }

        public void SetErrorCode(object code)
        {
            ErrorCode = code.ToString();
        }

            public void SetError(string error)
        {
            if(string.IsNullOrEmpty(ErrorMessage))
            {
                ErrorMessage = error;
            }
            else
            {
                ErrorMessage += "$";
                ErrorMessage += error;
            }
        }
    }
}
